<?php
//抽奖类
class opensslClassAction extends Action
{   
	//$lx=2详情,$lx=3是flow.php getdatalog下读取的
	public function getFileStrYulanAjax(){ 
	    $rs  = $this->request("id");  
		$fstr= '';
		if(!$rs)return $fstr;
		$file_src = m("file")->getone("id='".$rs."'");
		$url_src  = ''.URL.$file_src['filepath'];

    	$url_src = $this->encrypt($url_src);
    	//$fstr.='<a href="http://ow365.cn/?i=22301&furl='.$url_src.'" target="_blank">点我预览</a>';
                
		return json_encode($url_src);
	}
	
	public function des( $key, $iv=0 ) {
		$key = "21139032";
        $iv  = "30715186"; //偏移量
    //key长度8例如:1234abcd
        $key;
        if( $iv == 0 ) {
            $key; //默认以$key 作为 iv
        } else {
            $iv; //mcrypt_create_iv ( mcrypt_get_block_size (MCRYPT_DES, MCRYPT_MODE_CBC), MCRYPT_DEV_RANDOM );
        }
    }
    
    public function encrypt($str) {
        $key = "21139032";
        $iv  = "30715186"; 
        //偏移量
    //加密，返回base64编码字符串，之后要替换"+"为 "_"， "/"为 "@"
        $data = openssl_encrypt($str,"DES-CBC",$key,OPENSSL_RAW_DATA,$iv);
        $sTemp = base64_encode($data );
        $sTemp = str_replace('+','_',$sTemp);
        $sTemp = str_replace('/','@',$sTemp);
        return $sTemp;
    }
    
    public function pkcs5Pad($text, $blocksize) {
        $pad = $blocksize - (strlen ( $text ) % $blocksize);
        return $text . str_repeat ( chr ( $pad ), $pad );
    }

}